package com.heima.client.article.fallback;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.client.article.IArticleClient;
import com.heima.model.common.dtos.*;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.common.pojos.article.ApArticle;
import com.heima.model.common.pojos.article.ApArticleConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

/**
 * @author 陈辉
 * @data 2024 15:43
 */
@Slf4j
@Component
public class ArticleClientFallback implements IArticleClient {
    /**
     * 保存或修改article文章信息
     *
     * @param articleDto
     * @return
     */
    @Override
    public ResponseResult syncArticle(ArticleDto articleDto) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult updateomment(CommentStatus commentStatus) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult articlesele(List<Long> entryIds) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @PostMapping("api/v1/article/getarticle/{userId}/{end}/{begin}")
    public List<ApArticle> getArticle(@PathVariable Integer userId, @PathVariable Date end, @PathVariable Date begin) {
        log.warn("article微服务调用失败，开启降级处理....");
        return null;
    }

    @Override
    public Page<ApArticle> getArticle2(Integer userId, Date end, Date begin, FindNewsDto findNewsDto) {
        log.warn("article微服务调用失败，开启降级处理....");
        return null;
    }


    @PostMapping("api/v1/article/iscomment/{id}")
    public ApArticleConfig getConfig(@PathVariable Long id) {
        log.warn("article微服务调用失败，开启降级处理....");
        return null;
    }

    @Override
    public ResponseResult updateArticle(ReadBehaviorDto behaviorDto) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    /**
     * 查询article文章信息
     *
     * @param articleDto
     * @return
     */
    @Override
    public ResponseResult loadArticle(ArticleDto articleDto) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    /**
     * 根据用户id查询用户信息
     *
     * @param userId
     * @return
     */
    @Override
    public ResponseResult queryByUserId(Integer userId) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult getUserInfo(Integer authorId) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    /**
     * 获取文章信息
     *
     * @return
     */
    @Override
    public ResponseResult getArticleList(@RequestParam(value = "beginDate", required = false) String beginDate,
                                         @RequestParam(value = "endDate", required = false) String endDate,
                                         @RequestParam("userId") Integer userId) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult getPage(String beginDate, String endDate, Integer page, Integer size, Integer userId) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult updateStatus(CommentStatus commentStatus) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult updateCollection(CollectionBehaviorDto behaviorDto) {
        log.warn("article微服务调用失败，开启降级处理....");
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }
}
